package com.aya.modules.friend;

import com.aya.project.UserContext;
import com.aya.tb.annotation.RequestMapping;
import com.aya.tb.annotation.ResponseBody;
import io.netty.channel.Channel;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import org.springframework.stereotype.Controller;

@Controller
public class LoginAction {

    @ResponseBody
    @RequestMapping(code = FriendCodes.LOGIN_REQ)
    public Object list(Channel channel) {
        AttributeKey<Object> user_context = AttributeKey.valueOf("USER_CONTEXT");
        Attribute<Object> userContextAttr = channel.attr(user_context);
        UserContext userContext = new UserContext();
        userContext.setUserId(5L);
        userContextAttr.set(userContext);
        //这里可以用protobuf,或者自定义类去返回。 支持和其他的终端交互
        return "登陆成功";
    }
}
